Skip to content

Ontology Service Integration#680

Open
Tanmay2028 wants to merge 49 commits intomasterfrom
ontology-service
Open

Ontology Service Integration#680
Tanmay2028 wants to merge 49 commits intomasterfrom
ontology-service

Conversation

@Tanmay2028
Copy link
Collaborator

This PR introduces a FastAPI-based ontology service for the NOMAD platform, enabling dynamic access to NeXus ontology superclasses via HTTP endpoints. The service also ensures the ontology file is always up-to-date with the latest commit from the NeXus definitions submodule and provides reasoning capabilities using Owlready2.

Key Features

  1. Ontology File Management:
    On startup, the service checks for the existence of the ontology OWL file corresponding to the latest commit hash. If missing, it regenerates the OWL file and updates the reference.

  2. Reasoning and Inference:
    The ontology is loaded and inferred using Owlready2’s reasoner. Inferred ontologies are cached in a temporary directory for efficient access.

  3. API Endpoints: /superclasses/{class_name}: Returns the list of superclasses for a given ontology class.

  4. Integration with pynxtools schema:
    The pynxtools schema fetches superclasses and populates metadata fields accordingly.

@lukaspie
Copy link
Collaborator

lukaspie commented Aug 1, 2025

Would probably also be good to add some tests for this service

@mkuehbach
Copy link
Collaborator

mkuehbach commented Aug 6, 2025

Good to see these efforts from OSCARS bear fruit. Before this is gets merged the following needs to happen:

  • Tests as mentioned by Lukas (negotiate this as fits within OSCARS)
  • An update of the documentation (e.g., in the learning section, diataxis) that briefly explains the service and how it affects the UI experience when pynxtools is used in NOMAD is required
  • It would be ideal if the NeXusOntology repo's size gets reduced specifically when the plan is to have it as another default submodule with pynxtools.
  • Versioning of the NeXusOntology and the NeXus definitions is something that needs to be discussed to have a clear strategy if these should be in sync or not. Ideal would be if there is a PID-resolvable version of the NeXusOntology that we hook into at least for releases, for development purposes I agree that could be overkill.

Having the last two bullet points fixed to enable a merge or not is negotiatable, the other bullet points need to be fixed for this to become merged.

@mkuehbach mkuehbach self-requested a review August 6, 2025 16:34
Copy link
Collaborator

@mkuehbach mkuehbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tanmay2028
Copy link
Collaborator Author

Good to see these efforts from OSCARS bear fruit. Before this is gets merged the following needs to happen:

  • Tests as mentioned by Lukas (negotiate this as fits within OSCARS)
  • An update of the documentation (e.g., in the learning section, diataxis) that briefly explains the service and how it affects the UI experience when pynxtools is used in NOMAD is required
  • It would be ideal if the NeXusOntology repo's size gets reduced specifically when the plan is to have it as another default submodule with pynxtools.
  • Versioning of the NeXusOntology and the NeXus definitions is something that needs to be discussed to have a clear strategy if these should be in sync or not. Ideal would be if there is a PID-resolvable version of the NeXusOntology that we hook into at least for releases, for development purposes I agree that could be overkill.

Having the last two bullet points fixed to enable a merge or not is negotiatable, the other bullet points need to be fixed for this to become merged.

@mkuehbach Thank you for the comments. I will proceed working on the first two points. I am not sure what can be done to reduce the size of NeXusOntology repo. @sanbrock Do you have some suggestions here?

Copy link
Collaborator

@lukaspie lukaspie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing just the docs for now. Please run mkdocs serve to check that they display fine.

Please also remove the package-lock.json

Copy link
Collaborator

@lukaspie lukaspie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better already, just a couple more points.

Please also don't just resolve conversations, but leave a small comment what you have done with the initial comment (can be as short as "implemented"). This makes it easier to keep track.

@lukaspie
Copy link
Collaborator

lukaspie commented Jan 7, 2026

Docs looks good now 👍

@Tanmay2028
Copy link
Collaborator Author

Docs looks good now 👍

Thank you!

@mkuehbach mkuehbach self-requested a review January 14, 2026 08:41
Copy link
Collaborator

@mkuehbach mkuehbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go from my side with edits made in the documentation, license statements in Python files to add.

Really useful edits and PR, good job @Tanmay2028, @lukaspie, and @sanbrock .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants